function upgradeMdl(modelName)
% copy everything in the model being imported to a copy of the model, so
% that Weichai can call polyspace normally. The copy of the model will thus
% become the work model.

orignalMdl = [fullfile(ProjectPathManager.getDirPath('model', modelName), modelName) '.slx'];
backupMdl = strrep(orignalMdl,'.slx','_original.slx');
backupMdlName = [modelName '_original'];
% make a copy of the existing model
if exist(backupMdl,'file') == 4 % 4 �� name is a Simulink? model or library file on your MATLAB search path.
    warning(['A backup model ' backupMdlName '.slx already exist. Overring the backup model...'])
end
bdclose all
movefile(orignalMdl,backupMdl)

% create a new model with the orignal model name in the model folder
mdlTemplateDir = ProjectPathManager.getDirPath('prj config root');
mdlTemplateName = fullfile(mdlTemplateDir, 'templates', 'model_templates', [ProjectNamingManager.getNameStr('model template') '.sltx']);

% Create a new model.
tmpModel = Simulink.createFromTemplate(mdlTemplateName, 'Name', modelName);
% rename the model configuration name
configObj = getActiveConfigSet(tmpModel);
configObj.Name = ProjectNamingManager.getNameStr('model template');
% save the new model with the model name
save_system(tmpModel, orignalMdl);
% copy all the content from the backup model into the new model
copyModelContent2NewModel(backupMdlName,modelName)

% close both models.
close_system(backupMdl,0);
save_system(orignalMdl);
close_system(orignalMdl);
disp(['Model ', modelName, ' updated.']);

end